package com.tuzhi.base.jpa.domain;

import com.tuzhi.base.jpa.enums.AndOrOperate;
import com.tuzhi.base.jpa.enums.QueryTypeEnum;

import java.util.ArrayList;
import java.util.List;

public class WhereStatementBO {

    List<QueryStatementBO> queryStatementBOList = new ArrayList<>();
    List<String> sortColList = new ArrayList<>();

    public WhereStatementBO addQuery(QueryStatementBO queryStatementBO) {
        queryStatementBOList.add(queryStatementBO);
        return this;
    }

    public WhereStatementBO addQuery(String propertyName) {
        return addQuery(new QueryStatementBO(propertyName, QueryTypeEnum.equal, AndOrOperate.and));
    }

    public WhereStatementBO addQuery
            (String propertyName, QueryTypeEnum queryTypeEnum, AndOrOperate andOrOperate) {
        return addQuery(new QueryStatementBO(propertyName, queryTypeEnum, andOrOperate));
    }

    public WhereStatementBO addQuery
            (String propertyName, QueryTypeEnum queryTypeEnum, AndOrOperate andOrOperate, boolean passNull) {
        return addQuery(
                new QueryStatementBO(propertyName, queryTypeEnum, andOrOperate)
                        .setPassNull(passNull));
    }

    public WhereStatementBO addQuery
            (String propertyName, QueryTypeEnum queryTypeEnum, AndOrOperate andOrOperate, boolean passNull, Class c) {
        return addQuery(
                new QueryStatementBO(propertyName, queryTypeEnum, andOrOperate)
                        .setPassNull(passNull).setValClass(c));
    }

    public WhereStatementBO addSort(String str) {
        sortColList.add(str);
        return this;
    }

    public List<QueryStatementBO> getQueryStatementBOList() {
        return queryStatementBOList;
    }

    public void setQueryStatementBOList(List<QueryStatementBO> queryStatementBOList) {
        this.queryStatementBOList = queryStatementBOList;
    }

    public List<String> getSortColList() {
        return sortColList;
    }

    public void setSortColList(List<String> sortColList) {
        this.sortColList = sortColList;
    }
}
